﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharpDemos
{
    class Equality : IEquatable<Equality>
    {
        public int custID { get; set; }

        public string custName { get; set; }

        public Equality(int custId,string custName)
        {
            this.custID = custId;
            this.custName = custName;
        }

        public override bool Equals(object right)
        {
            if (object.ReferenceEquals(right, null))
            {
                return false;
            }

            if (object.ReferenceEquals(this, right))
            {
                return true;
            }

            if (this.GetType() != right.GetType())
            {
                return false;
            }

            return this.Equals(right);
        }

        public bool Equals(Equality other)
        {
            if (other == null)
                return false;

            if (object.ReferenceEquals(this, other))
                return true;

            if (this.custID == other.custID && this.custName == other.custName)
                return true;

            return false;
        }

        public static bool operator ==(Equality e1,Equality e2)
        {
            if (e1.custID == e2.custID && e1.custName == e2.custName)
                return true;

            return false;
        }

        public static bool operator !=(Equality e1, Equality e2)
        {
            if (e1.custID == e2.custID && e1.custName == e2.custName)
                return false;

            return true;
        }
    }
}
